/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/plus-one
   @Language: C++
   @Datetime: 19-07-02 10:39
   */

class Solution {
public:
	vector<int> plusOne(vector<int>& digits) {
		digits.insert(digits.begin(),0);
		for(int i=digits.size(), carry=1; i-- && carry; carry/=10){
			carry+=digits[i];
			digits[i]=carry%10;
		}
		if(digits[0]==0) digits.erase(digits.begin());
		return digits;
	}
};
